﻿Ext
		.onReady(function() {
			Ext.QuickTips.init();
			Ext.form.Field.prototype.msgTarget = 'under';
		
			
			
			var classrooms = new Ext.data.Record.create( [ {
				name : 'id',
				type : 'int'
			},  {
				name : 'name',
				type : 'string'
			} ,{
				name : 'number',
				type : 'int'
			},{
				name : 'teachingbuilding.teachingbuilding_name',
				type : 'String'
			}
			]);
			var classroomsstore = new Ext.data.Store( {
				proxy : new Ext.data.HttpProxy( {
					url : '/schedule/queryClassroom'
				}),
				reader : new Ext.data.JsonReader( {
					totalProperty : 'totalProperty',
					root : 'root'
				}, classrooms),
				remoteSort : true
			});
			classroomsstore.load();
			var classroomsSm = new Ext.grid.CheckboxSelectionModel({singleSelect : false});
			var classroomsCols = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(),
			       classroomsSm, {
						header : '教室名称',
						dataIndex : 'name'
					}, {
						header : '教室人数',
						dataIndex : 'number'
					}, {
						header : '所属教学楼',
						dataIndex : 'teachingbuilding.teachingbuilding_name'
					}]);
			classroomsCols.defaultSortable = true;

			var classroomsGrid = new Ext.grid.GridPanel(
					{
						title : '教室信息列表',
						region : 'west',
						buttonAlign : "left",
						width : 250,
						height : 460,
						loadMask : true,
						store : classroomsstore,
						disableSelection : false,
						cm : classroomsCols,
						sm :classroomsSm,
						viewConfig : {
							forceFit : true
						},
						bbar : new Ext.PagingToolbar( {
							store : classroomsstore,
							pageSize : 15,// 页大小
							displayInfo : true,// 是否显示displayMsg
							displayMsg : "本页显示第{0}条到第{1}条的记录,一共{2}条",
							emptyMsg : "没有记录"// 如果没有记录，则显示该文本
						}),
						listeners:{
							"rowdblclick" : function(grid, rowIndex, e) {
								var classroom_id = grid.getSelectionModel().getSelections()[0].get("id");
								var classroom_name = grid.getSelectionModel().getSelections()[0].get("name");
								var classroom_teachingbuilding = grid.getSelectionModel().getSelections()[0].get("teachingbuilding.teachingbuilding_name");
								var newwin = window.showModelessDialog("courseListByClassroom.jsp", classroom_id+","+classroom_teachingbuilding+"-"+classroom_name, "dialogTop:500px;dialogWidth:800px;dialogHeight:500px;location=no;resizable:yes; dialogLeft:300px;modal=yes");
								//var newwin = window.showModalDialog("courseListByClassroom.jsp", classroom_id+","+classroom_teachingbuilding+"-"+classroom_name, "dialogTop:100px;dialogWidth:1000px;dialogHeight:600px;location=no; dialogLeft:300px;modal=yes");
							}
						}
					});
			var classroomform = new Ext.form.FormPanel( {
				id : 'classroomform',
				width : 250,
				height : 460,
				renderTo:'foot2',
				hideBorders : true,
				labelWidth : 80,
				labelAlign : "right",
				items :classroomsGrid
			});
			
			
			var teachers = new Ext.data.Record.create( [ {
				name : 'teachers_id',
				type : 'int'
			}, {
				name : 'teachers_name',
				type : 'string'
			}, {
				name : 'teachers_code',
				type : 'string'
			} ]);
			

			var teacherstore = new Ext.data.Store( {
				proxy : new Ext.data.HttpProxy( {
					url : '/schedule/queryTeachers'
				}),
				reader : new Ext.data.JsonReader( {
					totalProperty : 'totalProperty',
					root : 'root'
				}, teachers),
				remoteSort : true
			});
			teacherstore.load();
			var teacherSm = new Ext.grid.CheckboxSelectionModel({singleSelect : false});
			var teacherCols = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(),
			           teacherSm, {
						header : '教师姓名',
						dataIndex : 'teachers_name'
					},{
						header : '教师编号',
						dataIndex : 'teachers_code'
					}]);
			teacherCols.defaultSortable = true;

			var teacherGrid = new Ext.grid.GridPanel(
					{
						title : '教师信息列表',
						region : 'center',
						buttonAlign : "left",
						width : 250,
						height : 460,
						loadMask : true,
						store : teacherstore,
						disableSelection : false,
						cm : teacherCols,
						sm :teacherSm,
						viewConfig : {
							forceFit : true
						},
						bbar : new Ext.PagingToolbar( {
							store : teacherstore,
							pageSize : 15,// 页大小
							displayInfo : true,// 是否显示displayMsg
							displayMsg : "本页显示第{0}条到第{1}条的记录,一共{2}条",
							emptyMsg : "没有记录"// 如果没有记录，则显示该文本
						}),
						listeners:{
							"rowdblclick" : function(grid, rowIndex, e) {
								var teachers_id = grid.getSelectionModel().getSelections()[0].get("teachers_id");
								var teachers_name = grid.getSelectionModel().getSelections()[0].get("teachers_name");
								var newwin = window.showModelessDialog("courseListByTeacher.jsp", teachers_id+","+teachers_name, "dialogTop:500px;dialogWidth:800px;dialogHeight:500px;location=no;resizable:yes; dialogLeft:200px;modal=yes");
								//var newwin = window.showModalDialog("courseListByTeacher.jsp", teachers_id+","+teachers_name, "dialogTop:100px;dialogWidth:1000px;dialogHeight:600px;location=no; dialogLeft:300px;modal=yes");
							}
						}
					});
			var teacherform = new Ext.form.FormPanel( {
				id : "form",
				width : 250,
				height :460,
				renderTo:'foot1',
				hideBorders : true,
				labelWidth : 80,
				labelAlign : "right",
				items :teacherGrid
			});
			
			var classes = new Ext.data.Record.create( [ {
				name : 'classes_id',
				type : 'int'
			}, {
				name : 'classes_name',
				type : 'string'
			},{
				name : 'classes_code',
				type : 'string'
			}]);
			
			var classesstore = new Ext.data.Store( {
				proxy : new Ext.data.HttpProxy( {
					url : '/schedule/queryClasses'
				}),
				reader : new Ext.data.JsonReader( {
					totalProperty : 'totalProperty',
					root : 'root'
				}, classes),
				remoteSort : true
			});
			classesstore.load();
			var classesSm = new Ext.grid.CheckboxSelectionModel({singleSelect : false});
			var classesCols = new Ext.grid.ColumnModel( [ new Ext.grid.RowNumberer(),
			           teacherSm, {
						header : '班级名称',
						dataIndex : 'classes_name'
					},{
						header : '班级编号',
						dataIndex : 'classes_code'
					}]);
			classesCols.defaultSortable = true;

			var classesGrid = new Ext.grid.GridPanel(
					{
						title : '班级信息列表',
						region : 'center',
						buttonAlign : "left",
						width : 250,
						height : 460,
						loadMask : true,
						store : classesstore,
						disableSelection : false,
						cm : classesCols,
						sm :classesSm,
						viewConfig : {
							forceFit : true
						},
						bbar : new Ext.PagingToolbar( {
							store : classesstore,
							pageSize : 15,// 页大小
							displayInfo : true,// 是否显示displayMsg
							displayMsg : "本页显示第{0}条到第{1}条的记录,一共{2}条",
							emptyMsg : "没有记录"// 如果没有记录，则显示该文本
						}),
						listeners:{
							"rowdblclick" : function(grid, rowIndex, e) {
								var classes_id = grid.getSelectionModel().getSelections()[0].get("classes_id");
								var classes_name = grid.getSelectionModel().getSelections()[0].get("classes_name");
								var newwin = window.showModelessDialog("courseListByClass.jsp", classes_id+"-"+classes_name, "dialogTop:500px;dialogWidth:800px;dialogHeight:500px;location=no;resizable:yes; dialogLeft:100px;modal=yes");
							}
						}
					});
			
			var classesform = new Ext.form.FormPanel( {
				id : "classesform",
				width : 250,
				height : 460,
				renderTo:'foot3',
				hideBorders : true,
				labelWidth : 80,
				labelAlign : "right",
				items :classesGrid
			});
		

		});